Skip to content

Corrected wrong Dijkstra priority queue implementation #909

Merged
poyea merged 4 commits into
TheAlgorithms:masterfrom
ziyzhu:master
Jun 23, 2019
Merged

Corrected wrong Dijkstra priority queue implementation #909
poyea merged 4 commits into
TheAlgorithms:masterfrom
ziyzhu:master

Conversation

@ziyzhu

@ziyzhu ziyzhu commented Jun 19, 2019

Copy link
Copy Markdown
Contributor

Given visited is a list(), "if v in visited:" is a O(n) operation in python which yields more complexity to this implementation as the if statement is nested in a for loop. Changing visited into a hash set grants only O(1) for checking "if v in visited:".

@poyea poyea left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this. Thank you for your pull request!🤩

@poyea poyea merged commit a212efe into TheAlgorithms:master Jun 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants